package gunfire.relics;

import basemod.abstracts.CustomRelic;
import com.badlogic.gdx.graphics.Texture;
import com.megacrit.cardcrawl.actions.common.RelicAboveCreatureAction;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.relics.AbstractRelic;
import gunfire.GunfireMod;
import gunfire.util.TextureLoader;

import static gunfire.GunfireMod.makeRelicOutlinePath;
import static gunfire.GunfireMod.makeRelicPath;

public class SpiritFeline extends CustomRelic {

    public static final String ID = GunfireMod.makeID("SpiritFeline");
    private static final Texture IMG = TextureLoader.getTexture(makeRelicPath("SpiritFeline.png"));
    private static final Texture OUTLINE = TextureLoader.getTexture(makeRelicOutlinePath("blank.png"));

    public SpiritFeline() {
        super(ID, IMG, OUTLINE, RelicTier.BOSS, LandingSound.CLINK);
    }

//    @Override
//    public int onAttacked(DamageInfo info, int damageAmount) {
//        int maxDamage = (int)Math.ceil(AbstractDungeon.player.maxHealth * 0.11F);
//        if (info.owner != null && info.type != DamageInfo.DamageType.HP_LOSS && info.type != DamageInfo.DamageType.THORNS && damageAmount > maxDamage) {
//            this.flash();
//            this.addToBot(new RelicAboveCreatureAction(AbstractDungeon.player, this));
//            return maxDamage;
//        } else {
//            return damageAmount;
//        }
//    }

    @Override
    public int onLoseHpLast(int damageAmount) {
        int maxDamage = (int)Math.ceil(AbstractDungeon.player.maxHealth * 0.11F);
        if(damageAmount > maxDamage){
            this.flash();
            return maxDamage;
        } else {
            return damageAmount;
        }
    }

    @Override
    public String getUpdatedDescription() {
        if(AbstractDungeon.player != null){
            return DESCRIPTIONS[0] + "( #b" + (int)Math.ceil(AbstractDungeon.player.maxHealth * 0.11F) + " )" + DESCRIPTIONS[1];
        }
        return DESCRIPTIONS[0] + DESCRIPTIONS[1];
    }

    @Override
    public AbstractRelic makeCopy() {
        return new SpiritFeline();
    }
}
